use serde::{Deserialize, Serialize};
use std::fmt::{Display, Formatter};
use utoipa::ToSchema;
use validator::Validate;

#[derive(Debug, Serialize, Deserialize, Validate)]
pub struct UserReqVo {
    #[validate(length(min = 3))]
    pub name: String,

    #[validate(length(min = 11))]
    pub phone: String,

    pub age: i8,

    pub sex: i8,

    #[validate(email)]
    pub email: String,

    #[validate(length(min = 8))]
    pub password: String,

    pub description: String,
}

impl Display for UserReqVo {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        write!(f, "{self:?}")
    }
}

#[derive(Debug, Serialize, Deserialize, Validate, ToSchema)]
pub struct UserLoginReqVo {
    #[validate(email)]
    pub email: String,

    #[validate(length(min = 8))]
    pub password: String,
}
